/*     */ package com.qmsk.business.task.trycartype.controller;
/*     */ 
/*     */ import com.qmsk.business.task.trycartype.dao.TryCarTypeDao;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"tryCarType"})
/*     */ public class TryCarTypeController
/*     */ {
/*  31 */   private static final Logger logger = Logger.getLogger(TryCarTypeController.class);
/*     */ 
/*     */   @Autowired
/*     */   private TryCarTypeDao dao;
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/id/{id}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId, @PathVariable("id") String id, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  52 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  54 */       Map params = new HashMap();
/*  55 */       params.put("shopId", shopId);
/*  56 */       MapUtils.addToMap(params, "id", id);
/*  57 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(params, nPageIdx, 
/*  58 */         nPageSize);
/*  59 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  61 */       logger.error(e);
/*  62 */       ResponseUtils.setErrorMsgResponse(
/*  63 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/opt/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListShopIdOpt(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") String shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  82 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  84 */       Map params = new HashMap();
/*  85 */       params.put("shopId", shopId);
/*  86 */       MapUtils.addToMap(params, "id", RequestUtils.getStringOfId(request));
/*  87 */       MapUtils.addPercentToMap(params, "code", 
/*  88 */         RequestUtils.getString(request, "code"));
/*  89 */       MapUtils.addPercentToMap(params, "name", 
/*  90 */         RequestUtils.getString(request, "name"));
/*  91 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(params, nPageIdx, 
/*  92 */         nPageSize);
/*  93 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  95 */       logger.error(e);
/*  96 */       ResponseUtils.setErrorMsgResponse(
/*  97 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/* 114 */       int nResult = 0;
/* 115 */       Long id = null;
/* 116 */       String sData = RequestUtils.getStringOfData(request);
/* 117 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 118 */       if (p != null) {
/* 119 */         nResult = this.dao.applyUpdates(p);
/* 120 */         if (nResult > 0) {
/* 121 */           id = this.dao.getLastId();
/* 122 */           DbConnection.commit();
/*     */         } else {
/* 124 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 127 */       if (id != null) {
/* 128 */         String[] heads = { "id" };
/* 129 */         Object[] datas = { id };
/* 130 */         ResponseUtils.toGsonEbRst(heads, datas, response);
/* 131 */         return; }
/* 132 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 133 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 134 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 137 */       logger.error(e);
/* 138 */       DbConnection.rollback();
/* 139 */       ResponseUtils.setErrorMsgResponse(
/* 140 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 141 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"edit/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void edit(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/* 158 */       int nResult = 0;
/* 159 */       String sData = RequestUtils.getStringOfData(request);
/* 160 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 161 */       if (p != null) {
/* 162 */         nResult = this.dao.applyUpdates(p);
/* 163 */         if (nResult > 0)
/* 164 */           DbConnection.commit();
/*     */         else {
/* 166 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 169 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 170 */         RequestUtils.getSqlUpdateDataErrorMessage(request), 
/* 171 */         response);
/*     */     } catch (Exception e) {
/* 173 */       logger.error(e);
/* 174 */       DbConnection.rollback();
/* 175 */       ResponseUtils.setErrorMsgResponse(
/* 176 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 177 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 193 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 195 */       String[] strParams = id.split(",");
/* 196 */       int nResult = this.dao.deleteParams(strParams);
/* 197 */       if (nResult > 0)
/* 198 */         DbConnection.commit();
/*     */       else {
/* 200 */         DbConnection.rollback();
/*     */       }
/* 202 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 203 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 204 */         response);
/*     */     } catch (Exception e) {
/* 206 */       DbConnection.rollback();
/* 207 */       logger.error(e);
/* 208 */       ResponseUtils.setErrorMsgResponse(
/* 209 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 210 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.task.trycartype.controller.TryCarTypeController
 * JD-Core Version:    0.5.3
 */